package com.ph.demo.JDKcurrent;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by peng on 2019/4/10.
 */
public class ConditionDemo implements Runnable{

    public static  ReentrantLock lock = new ReentrantLock();

    public  static Condition condition = lock.newCondition();

    @Override
    public void run() {

        try {
            lock.lock();
            condition.await();
            System.out.println("go on");
        }catch (Exception e){

        } finally {
            lock.unlock();
        }

    }

    public static void main(String[] args) throws Exception{
        ConditionDemo conditionDemo = new ConditionDemo();

        Thread thread = new Thread(conditionDemo);

        thread.start();

        Thread.sleep(1);

        lock.lock();

        condition.signal();

        lock.unlock();
    }
}
